<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        <h1>{{msg}}</h1>
        <app></app>
    </div>

    <script type="text/javascript">

        const student = Vue.extend({
            name: 'student',
            template: `
                <div>
                    <h2>学生姓名:{{name}}</h2>
                    <h2>学生年龄:{{age}}</h2>
                </div>
            `,
            data: function () {
                return {
                    name: '张三',
                    age: 18
                }
            }
        })

        const school = Vue.extend({
            name: 'school',
            template: `
                <div>
                    <h2>学校名称:{{name}}</h2>
                    <h2>学校地址:{{address}}</h2>
                    <student></student>
                </div>
            `,
            data: function () {
                return {
                    name: '尚硅谷',
                    address: '北京'
                }
            },
            components: {
                student
            }
        })

        const hello = Vue.extend({
            name: 'hello',
            template: `
                <div>
                    <h2>{{sql}}</h2>
                </div>
            `,
            data: function () {
                return {
                    sql: '你好啊'
                }
            }
        })

        const app = Vue.extend({
            template:`
                <div>
                    <hello></hello>
                    <school></school>
            `,
            components:{
                school,
                hello
            }
        })



        new Vue({
            el: '#root',
            data: {
                msg: '欢迎学习Vue!'
            },
            components: {
                app
            }
        })
    </script>

</body>

</html>